FROM openjdk:8u151-jdk-alpine3.7
MAINTAINER "Cloth Mo" <root@buxiaomo.com>

COPY repositories /etc/apk/repositories

ENV ANT_VERSION 1.10.1
ENV ANT_HOME /usr/share/ant
RUN wget http://mirrors.tuna.tsinghua.edu.cn/apache/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz \
    && mkdir ant-${ANT_VERSION} \
    && tar -zxf apache-ant-${ANT_VERSION}-bin.tar.gz \
    && mv apache-ant-${ANT_VERSION} ${ANT_HOME} \
    && rm -rf ant-${ANT_VERSION} ${ANT_HOME}/manual /tmp \
    && unset ANT_VERSION
ENV PATH $PATH:$ANT_HOME/bin

RUN apk add --no-cache maven
ENV MAVEN_HOME /usr/share/java/maven-3
ENV PATH $PATH:$MAVEN_HOME/bin

ENV DOCKER_CHANNEL stable
ENV DOCKER_VERSION 17.12.0-ce
RUN apk add --no-cache git \
    && mkdir /usr/local/src/ \
    && wget -O /usr/local/src/docker.tgz "https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz" \
    && tar --strip-components=1 -zxf /usr/local/src/docker.tgz -C /usr/local/bin \
    && rm -rf /usr/local/src/docker.tgz \
    && unset DOCKER_CHANNEL && unset DOCKER_VERSION

ENV Jenkins_Version 2.89.3
RUN mkdir -p /usr/share/jenkins /var/jenkins \
    && wget -O /usr/share/jenkins/jenkins.war https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/${Jenkins_Version}/jenkins.war

ENV JENKINS_HOME /var/jenkins

EXPOSE 8080
VOLUME /var/jenkins

CMD ["java","-Dhudson.util.ProcessTree.disable=true","-jar","/usr/share/jenkins/jenkins.war"]
